﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using cancerportal.Data;
namespace cancerportal.Models
{
    public class dictionaryModels : DataBaseConnection
    {
        public static void insertIntoDictionary(string newWord)
        {
            string query = "insert into cancerportal.dbo.dictionary(word_content) values (@content)";
            try
            {
                open();
                DBCommand.CommandText = query;
                DBCommand.Parameters.AddWithValue("@content", newWord);
                DBCommand.ExecuteNonQuery();
            }
            finally
            {
                close();
            }
        }

        public static bool checkExistWord(string word)
        {
            bool test = false;
            string query = "select * from cancerportal.dbo.dictionary where word_content = @word";
            try
            {
                open();
                DBCommand.CommandText = query;
                DBCommand.Parameters.AddWithValue("@word", word);
                reader = DBCommand.ExecuteReader();
                if (reader.Read())
                {
                    test = true;
                }
            }
            finally
            {
                close();
            }
            return test;
        }
    }
}